//In the word type, first the low byte and then the high
typedef struct header
{
	char String[2];
	char Byte2;
	char Byte3; //Here is the version number
} header;

typedef struct ConfigFrame
{
	//Header
	header Header;
	//General
	char SampleRate[2];
	char NullBytes[6];
	//Address
	char Address[32];
	//
	char ChDevice[32];
	char ToFill[56];		//Serve per arrivare a 132 byte
} ConfigFrame;

typedef struct RequestFrame
{
	//Header
	header Header;
	//To Fill
	char ToFill[128];
} requestFrame;

typedef struct DataFrame64
{
	//General data field
	char Checksum[2];
	char SampleRate[2];
	char Overflow;
	char Patientkey;
	//General bits status
	char Digital[2];
	char TimeStamp[8]; //Only for Braintronics test
	char FrameCount[4];
	//Data fields
	WORD Data[64];
	WORD Status[64];
} DataFrame64;

typedef struct DataFrame32
{
	//General data field
	char Checksum[2];
	char SampleRate[2];
	char Overflow;
	char Patientkey;
	//General bits status
	char Digital[2];
	char TimeStamp[8]; //Only for Braintronics test
	char FrameCount[4];
	//Data fields
	WORD Data[32];
	WORD Status[32];
} DataFrame32;


typedef struct IntControlFrame
{
	header Header;
	char NotchControl;
	char NotchBW;
	char SampleRate[2];
	char ToFill[124];
} IntControlFrame;

typedef struct ControlFrame
{
	header Header;
	//Control Field
	char Array[128];
} ControlFrame;

typedef struct ExtendedControlFrame
{
	header Header;
	//Control Field
	char Array[4];
	char ReplayDalay[2];
	char ToFil[122];
} ExtendedControlFrame;

typedef struct DigioutFrame
{
	header Header;
	char Digit;
	char ToFill[127];
} DigioutFrame;

typedef struct CastFrame
{
	char bytes[132];
} CastFrame;

class NetworkProtocol
{

public:
	NetworkProtocol();
	~NetworkProtocol();
	
	
	int NumDevice;
	int Num1042;
	int Num1142;
	int Num64;
	int Num66;
	int Flash_201;

	ConfigFrame		VConfigFrame;
	RequestFrame	VRequestFrame;
	DataFrame32		VDataFrame32;
	DataFrame64		VDataFrame64;
	IntControlFrame	VIntControlFrame;
	ControlFrame	VControlFrame;
    ExtendedControlFrame	VExtendedControlFrame;
	DigioutFrame	VDigioutFrame;
	header			VHeader;

	void SetConfigFrame(int SampleRate);
	int AddDevices(wxString Devices,int NumDevice);
	void SetStartFrame(void);
	void SetStopFrame(void);
	void SetEEGMode(void);
	void SetImpedanceMode(void);
	void SetCalibrationMode(void);

	
private:
	void ResetFrame (CastFrame *Frame);
};

